﻿define(["angular", "angular-mocks"], function (angular) {
    describe('dateValidation', function () {
        var scope;
        var controller;
        var $provide;
        var Services;
        var myServiceName = function ($http) {
            // do stuff
        };
        beforeEach(function () {
            module('dateValidation');
            module(function ($provide) {
                $provide.service('Services', myServiceName);
            });
            inject(function ($injector) {
                Services = $injector.get('Services');
            });
        });

        describe('dateValidator', function () {
            beforeEach(inject(function ($rootScope, $controller) {
                scope = $rootScope.$new();
                controller = $controller('dateValidator', {
                    '$scope': scope
                });
            }));
            it('dateTime convertion', function () {
                expect(scope.getDateTimeString(new Date(2004, 2, 08))).toBe('08.03.2004 00:00');
            });

            it('date convertion', function () {
                expect(scope.getDateString(new Date(2004, 2, 8))).toBe('08.03.2004');
            });

            it('check old match success', function () {
                expect(scope.checkOldMatch('08.03.2004 00:00', new Date(2007, 5, 10)).getTime()).toBe(new Date(2004, 2, 8).getTime());
            });

            it('check old match fail', function () {
                expect(scope.checkOldMatch('08.032004 00:00', new Date(2007, 5, 10)).getTime()).toBe(new Date(2007, 5, 10).getTime());
            });

        });
    });

    describe('portModule', function () {
        var scope;
        var controller;
        var $provide;
        var Services;
        var myServiceName = function ($http) {
            // do stuff
        };

        beforeEach(function () {
            module('portModule');
            module(function ($provide) {
                $provide.service('Services', myServiceName);
            });
            inject(function ($injector) {
                Services = $injector.get('Services');
            });
        });

        describe('PortCtrl', function () {
            beforeEach(inject(function ($rootScope, $controller) {
                scope = $rootScope.$new();
                controller = $controller('PortCtrl', {
                    '$scope': scope
                });
            }));
            it('init port', function () {
                scope.init(null, 'load', 20);
                expect(scope.type).toBe('load');
                expect(scope.data).toBe(null);
                expect(scope.id).toBe(20);
            });
            it('change marker time + 6', function () {
                document.getElementById = jasmine.createSpy('HTML Element').and.returnValue([]);
                scope.getParent = jasmine.createSpy('parent Index').and.returnValue(0);
                scope.data = [
                    {
                        AAMarker: '',
                        AATime: new Date(2014, 1, 1),
                        Chat: null,
                        ETA_NORTime: new Date(2011, 5, 16, 7),
                        ETAMarker: 'NOR',
                        ETB_ATBTime: new Date(2011, 5, 16),
                        ETBMarker: 'ETB',
                        ETCMarker: null,
                        ETD_ATDTime: new Date(2011, 2, 2, 14),
                        ETDMarker: 'HD',
                        FinalCalculationOption: 0,
                        Laytime: null,
                        Name: '(No_Name)',
                        Notes: null,
                        Sequence: 0,
                        SldDate: null,
                        Zone: null
                    }
                ];
                scope.temp = { ETAMarker: 'NOR+6h' };
                scope.checkMarkerTime();
                expect(scope.data[0].ETA_NORTime.getHours()).toBe(13);
            });
            it('change marker time - 6', function () {
                document.getElementById = jasmine.createSpy('HTML Element').and.returnValue([]);
                scope.getParent = jasmine.createSpy('parent Index').and.returnValue(0);
                scope.data = [
                    {
                        AAMarker: '',
                        AATime: new Date(2014, 1, 1),
                        Chat: null,
                        ETA_NORTime: new Date(2011, 5, 16, 7),
                        ETAMarker: 'NOR+6h',
                        ETB_ATBTime: new Date(2011, 5, 16),
                        ETBMarker: 'ETB',
                        ETCMarker: null,
                        ETD_ATDTime: new Date(2011, 2, 2, 14),
                        ETDMarker: 'HD',
                        FinalCalculationOption: 0,
                        Laytime: null,
                        Name: '(No_Name)',
                        Notes: null,
                        Sequence: 0,
                        SldDate: null,
                        Zone: null
                    }
                ];
                scope.temp = { ETAMarker: 'NOR' };
                scope.checkMarkerTime();
                expect(scope.data[0].ETA_NORTime.getHours()).toBe(1);
            });
            it('change marker time no changes', function () {
                document.getElementById = jasmine.createSpy('HTML Element').and.returnValue([]);
                scope.getParent = jasmine.createSpy('parent Index').and.returnValue(0);
                scope.data = [
                    {
                        AAMarker: '',
                        AATime: new Date(2014, 1, 1),
                        Chat: null,
                        ETA_NORTime: new Date(2011, 5, 16, 7),
                        ETAMarker: 'ETA',
                        ETB_ATBTime: new Date(2011, 5, 16),
                        ETBMarker: 'ETB',
                        ETCMarker: null,
                        ETD_ATDTime: new Date(2011, 2, 2, 14),
                        ETDMarker: 'HD',
                        FinalCalculationOption: 0,
                        Laytime: null,
                        Name: '(No_Name)',
                        Notes: null,
                        Sequence: 0,
                        SldDate: null,
                        Zone: null
                    }
                ];
                scope.temp = { ETAMarker: 'NOR' };
                scope.checkMarkerTime();
                expect(scope.data[0].ETA_NORTime.getHours()).toBe(7);
            });
            it('increase selected value', function () {
                scope.getParent = jasmine.createSpy('get parent Index').and.returnValue(2);
                scope.assignParent = jasmine.createSpy(' set parent Index').and.returnValue(2);
                scope.UpdateSelected = jasmine.createSpy('update').and.returnValue(2);
                scope.temp = { selected: '2' };
                scope.data = [{
                    Name: '0',
                    Sequence: 0
                }, {
                    Name: '1',
                    Sequence: 1
                }, {
                    Name: '2',
                    Sequence: 2
                }, {
                    Name: '3',
                    Sequence: 3
                }, {
                    Name: '4',
                    Sequence: 4
                }
                ];
                scope.increaseSelectedValue();
                expect(scope.temp.selected).toBe('3');
                expect(scope.data[3].Sequence).toBe(3);
                scope.getParent = jasmine.createSpy('get parent Index').and.returnValue(0);
                expect(scope.temp.selected).toBe('3');
            });
            it('decrease selected value', function () {
                scope.getParent = jasmine.createSpy('get parent Index').and.returnValue(2);
                scope.assignParent = jasmine.createSpy(' set parent Index').and.returnValue(2);
                scope.UpdateSelected = jasmine.createSpy('update').and.returnValue(2);
                scope.temp = { selected: '2' };
                scope.data = [{
                    Name: '0',
                    Sequence: 0
                }, {
                    Name: '1',
                    Sequence: 1
                }, {
                    Name: '2',
                    Sequence: 2
                }, {
                    Name: '3',
                    Sequence: 3
                }, {
                    Name: '4',
                    Sequence: 4
                }
                ];
                scope.decreaseSelectedValue();
                expect(scope.temp.selected).toBe('1');
                expect(scope.data[1].Sequence).toBe(1);
                scope.getParent = jasmine.createSpy('get parent Index').and.returnValue(0);
                expect(scope.temp.selected).toBe('1');
            });
            it('check name of port', function () {
                scope.temp = { name: '2' };
                scope.data = [{
                    Name: '0',
                    Sequence: 0
                }, {
                    Name: '1',
                    Sequence: 1
                }, {
                    Name: '2',
                    Sequence: 2
                }, {
                    Name: '3',
                    Sequence: 3
                }, {
                    Name: '4',
                    Sequence: 4
                }
                ];
                scope.checkName();
                expect(scope.checkName()).toBe(false);
                scope.temp = { name: 'sd' };
                expect(scope.checkName()).toBe(true);
                scope.temp = { name: '' };
                expect(scope.checkName()).toBe(false);
            });
        });
    });

    describe('calculationModule', function () {
        var scope;
        var controller;
        var $provide;
        var Services;
        var myServiceName = function ($http) {
            // do stuff
        };

        beforeEach(function () {
            module('calculationModule');
            module(function ($provide) {
                $provide.service('Services', myServiceName);
            });
            inject(function ($injector) {
                Services = $injector.get('Services');
            });
        });

        describe('calcualtor', function () {
            beforeEach(inject(function ($rootScope, $controller) {
                scope = $rootScope.$new();
                controller = $controller('calcualtor', {
                    '$scope': scope
                });
            }));
            it('init calculation', function () {
                scope.initCalc('load', 10);
                expect(scope.type).toBe('load');
                expect(scope.id).toBe(10);
            });
            it('substract dates', function () {
                expect(scope.substractDates(new Date(2004, 0, 1), new Date(2004, 0, 2))).toBe(-24);
                expect(scope.substractDates(new Date(2004, 0, 2), new Date(2004, 0, 1))).toBe(24);
                expect(scope.substractDates(new Date(2004, 0, 20), new Date(2004, 0, 1))).toBe(24 * 19);
                expect(scope.substractDates(new Date(2011, 5, 16), new Date(2011, 2, 2, 14))).toBe(2530);
                expect(scope.substractDates(new Date(2011, 2, 2, 14), new Date(2011, 5, 16))).toBe(-2530);
                expect(scope.substractDates(new Date(2014, 4, 1), new Date(2014, 1, 1))).toBe(24 * 89);
                expect(scope.substractDates(new Date(2014, 1, 1), new Date(2014, 4, 1))).toBe(-24 * 89);
            });
            it('calculation case 1 success', function () {
                scope.port = {
                    AAMarker: 'Anchor aweigh',
                    AATime: new Date(2014, 1, 1),
                    Chat: null,
                    ETA_NORTime: new Date(2014, 4, 1),
                    ETAMarker: 'NOR+6h',
                    ETB_ATBTime: new Date(2011, 5, 16),
                    ETBMarker: 'ETB',
                    ETCMarker: null,
                    ETD_ATDTime: new Date(2011, 2, 2, 14),
                    ETDMarker: 'HD',
                    FinalCalculationOption: 0,
                    Laytime: null,
                    Name: '(No_Name)',
                    Notes: null,
                    Sequence: 0,
                    SldDate: null,
                    Zone: null
                };
                scope.calcCase1();
                expect(scope.calculations.HDNOR).toBe(scope.substractDates(scope.port.ETD_ATDTime, scope.port.ETA_NORTime));
                expect(scope.calculations.ETBAnch).toBe(scope.substractDates(scope.port.ETB_ATBTime, scope.port.AATime));
                expect(scope.calculations.TotalTime).toBe(scope.calculations.HDNOR - scope.calculations.ETBAnch);
            });
            it('calculation case 2 success', function () {
                scope.port = {
                    AAMarker: '',
                    AATime: new Date(2014, 1, 1),
                    Chat: null,
                    ETA_NORTime: new Date(2014, 4, 1),
                    ETAMarker: 'NOR+6h',
                    ETB_ATBTime: new Date(2011, 5, 16),
                    ETBMarker: 'ATB',
                    ETCMarker: null,
                    ETD_ATDTime: new Date(2011, 2, 2, 14),
                    ETDMarker: 'HD',
                    FinalCalculationOption: 0,
                    Laytime: null,
                    Name: '(No_Name)',
                    Notes: null,
                    Sequence: 0,
                    SldDate: null,
                    Zone: null
                };
                scope.calcCase2();
                expect(scope.calculations.HDATB).toBe(scope.substractDates(scope.port.ETD_ATDTime, scope.port.ETB_ATBTime));
                expect(scope.calculations.TotalTime).toBe(scope.calculations.HDATB);
            });
            it('calculation case 4 and 5 with 0 success', function () {
                scope.port = {
                    AAMarker: 'Anchor aweigh',
                    AATime: new Date(2014, 1, 1),
                    Chat: null,
                    ETA_NORTime: new Date(2014, 4, 1),
                    ETAMarker: 'NOR',
                    ETB_ATBTime: new Date(2011, 5, 16),
                    ETBMarker: 'ETB',
                    ETCMarker: null,
                    ETD_ATDTime: new Date(2011, 2, 2, 14),
                    ETDMarker: 'HD',
                    FinalCalculationOption: 0,
                    Laytime: null,
                    Name: '(No_Name)',
                    Notes: null,
                    Sequence: 0,
                    SldDate: null,
                    Zone: null
                };
                scope.calcCase4and5();
                expect(scope.calculations.CaseFour).toBe(scope.substractDates(scope.port.ETD_ATDTime, scope.port.ETB_ATBTime));
                expect(scope.calculations.LessShifting).toBe(scope.substractDates(scope.port.ETB_ATBTime, scope.port.AATime));
                expect(scope.calculations.TotalTime).toBe(scope.calculations.CaseFour - scope.calculations.LessShifting);
            });
            it('calculation case 4 and 5 with 1 success', function () {
                scope.port = {
                    AAMarker: 'Anchor aweigh',
                    AATime: new Date(2014, 1, 1),
                    Chat: null,
                    ETA_NORTime: new Date(2014, 4, 1),
                    ETAMarker: 'NOR',
                    ETB_ATBTime: new Date(2011, 5, 16),
                    ETBMarker: 'ETB',
                    ETCMarker: null,
                    ETD_ATDTime: new Date(2011, 2, 2, 14),
                    ETDMarker: 'HD',
                    FinalCalculationOption: 1,
                    Laytime: null,
                    Name: '(No_Name)',
                    Notes: null,
                    Sequence: 0,
                    SldDate: null,
                    Zone: null
                };
                scope.calcCase4and5();
                expect(scope.calculations.CaseFour).toBe(scope.substractDates(scope.port.ETD_ATDTime, scope.port.ETA_NORTime));
                expect(scope.calculations.LessShifting).toBe(scope.substractDates(scope.port.ETB_ATBTime, scope.port.AATime));
                expect(scope.calculations.TotalTime).toBe(scope.calculations.CaseFour - scope.calculations.LessShifting);
            });
            it('calculation case 4 and 5 with 1 and aa=null success', function () {
                scope.port = {
                    AAMarker: '',
                    AATime: new Date(2014, 1, 1),
                    Chat: null,
                    ETA_NORTime: new Date(2014, 4, 1),
                    ETAMarker: 'NOR',
                    ETB_ATBTime: new Date(2011, 5, 16),
                    ETBMarker: 'ETB',
                    ETCMarker: null,
                    ETD_ATDTime: new Date(2011, 2, 2, 14),
                    ETDMarker: 'HD',
                    FinalCalculationOption: 1,
                    Laytime: null,
                    Name: '(No_Name)',
                    Notes: null,
                    Sequence: 0,
                    SldDate: null,
                    Zone: null
                };
                scope.calcCase4and5();
                expect(scope.calculations.CaseFour).toBe(scope.substractDates(scope.port.ETD_ATDTime, scope.port.ETA_NORTime));
                expect(scope.calculations.LessShifting).toBe(0);
                expect(scope.calculations.TotalTime).toBe(scope.calculations.CaseFour - scope.calculations.LessShifting);
            });
            it('calculation case 4 and 5 with 0 and aa=null success', function () {
                scope.port = {
                    AAMarker: '',
                    AATime: new Date(2014, 1, 1),
                    Chat: null,
                    ETA_NORTime: new Date(2014, 4, 1),
                    ETAMarker: 'NOR',
                    ETB_ATBTime: new Date(2011, 5, 16),
                    ETBMarker: 'ETB',
                    ETCMarker: null,
                    ETD_ATDTime: new Date(2011, 2, 2, 14),
                    ETDMarker: 'HD',
                    FinalCalculationOption: 0,
                    Laytime: null,
                    Name: '(No_Name)',
                    Notes: null,
                    Sequence: 0,
                    SldDate: null,
                    Zone: null
                };
                scope.calcCase4and5();
                expect(scope.calculations.CaseFour).toBe(scope.substractDates(scope.port.ETD_ATDTime, scope.port.ETB_ATBTime));
                expect(scope.calculations.LessShifting).toBe(0);
                expect(scope.calculations.TotalTime).toBe(scope.calculations.CaseFour - scope.calculations.LessShifting);
            });
            it('is full field port success', function () {
                var port = {
                    AAMarker: '',
                    AATime: new Date(2014, 1, 1),
                    Chat: null,
                    ETA_NORTime: new Date(2014, 4, 1),
                    ETAMarker: 'NOR',
                    ETB_ATBTime: new Date(2011, 5, 16),
                    ETBMarker: 'ETB',
                    ETCMarker: null,
                    ETD_ATDTime: new Date(2011, 2, 2, 14),
                    ETDMarker: 'HD',
                    FinalCalculationOption: 0,
                    Laytime: null,
                    Name: '(No_Name)',
                    Notes: null,
                    Sequence: 0,
                    SldDate: null,
                    Zone: null
                };
                expect(scope.isFullfilled(port)).toBe(true);
            });
            it('is full field port fail', function () {
                var port = {
                    AAMarker: '',
                    AATime: new Date(2014, 1, 1),
                    Chat: null,
                    ETA_NORTime: null,
                    ETAMarker: 'NOR',
                    ETB_ATBTime: new Date(2011, 5, 16),
                    ETBMarker: 'ETB',
                    ETCMarker: null,
                    ETD_ATDTime: new Date(2011, 2, 2, 14),
                    ETDMarker: 'HD',
                    FinalCalculationOption: 0,
                    Laytime: null,
                    Name: '(No_Name)',
                    Notes: null,
                    Sequence: 0,
                    SldDate: null,
                    Zone: null
                };
                expect(scope.isFullfilled(port)).toBe(false);
            });
            it('is full field port in case success', function () {
                var port = {
                    AAMarker: '',
                    AATime: null,
                    Chat: null,
                    ETA_NORTime: new Date(2014, 4, 1),
                    ETAMarker: 'NOR',
                    ETB_ATBTime: new Date(2011, 5, 16),
                    ETBMarker: 'ETB',
                    ETCMarker: null,
                    ETD_ATDTime: new Date(2011, 2, 2, 14),
                    ETDMarker: 'HD',
                    FinalCalculationOption: 0,
                    Laytime: null,
                    Name: '(No_Name)',
                    Notes: null,
                    Sequence: 0,
                    SldDate: null,
                    Zone: null
                };
                expect(scope.isFullfilledCase(port)).toBe(true);
            });
            it('is full field port in case fail', function () {
                var port = {
                    AAMarker: '',
                    AATime: new Date(2014, 1, 1),
                    Chat: null,
                    ETA_NORTime: null,
                    ETAMarker: 'NOR',
                    ETB_ATBTime: new Date(2011, 5, 16),
                    ETBMarker: 'ETB',
                    ETCMarker: null,
                    ETD_ATDTime: new Date(2011, 2, 2, 14),
                    ETDMarker: 'HD',
                    FinalCalculationOption: 0,
                    Laytime: null,
                    Name: '(No_Name)',
                    Notes: null,
                    Sequence: 0,
                    SldDate: null,
                    Zone: null
                };
                expect(scope.isFullfilledCase(port)).toBe(false);
            });

            it('get conditions 1', function () {
                scope.isFullfilled = jasmine.createSpy('return true').and.returnValue(true);
                var port = {
                    AAMarker: 'Anchor aweigh',
                    ETAMarker: 'NOR+6h',
                    ETBMarker: 'ETB',
                    ETDMarker: 'HD'
                };
                expect(scope.getCondition(port)).toBe(1);
                port.ETDMarker = 'ETD';
                expect(scope.getCondition(port)).toBe(1);
                port.ETBMarker = 'ATB';
                expect(scope.getCondition(port)).toBe(1);
                port.ETDMarker = 'HD';
                expect(scope.getCondition(port)).toBe(1);
            });

            it('get conditions 2', function () {
                scope.isFullfilled = jasmine.createSpy('return true').and.returnValue(true);
                var port = {
                    AAMarker: '',
                    ETAMarker: 'NOR+6h',
                    ETBMarker: 'ATB',
                    ETDMarker: 'HD'
                };
                expect(scope.getCondition(port)).toBe(2);
                port.ETDMarker = 'ETD';
                expect(scope.getCondition(port)).toBe(2);
            });

            it('get conditions 4', function () {
                scope.isFullfilled = jasmine.createSpy('return true').and.returnValue(true);
                var port = {
                    AAMarker: '',
                    ETAMarker: 'NOR',
                    ETBMarker: 'ETB',
                    ETDMarker: 'HD'
                };
                expect(scope.getCondition(port)).toBe(4);
                port.ETDMarker = 'ETD';
                expect(scope.getCondition(port)).toBe(4);
                port.AAMarker = 'Anchor aweigh';
                expect(scope.getCondition(port)).toBe(4);
                port.ETDMarker = 'HD';
                expect(scope.getCondition(port)).toBe(4);
            });

            it('get conditions 5', function () {
                scope.isFullfilled = jasmine.createSpy('return true').and.returnValue(true);
                var port = {
                    AAMarker: '',
                    ETAMarker: 'NOR',
                    ETBMarker: 'ATB',
                    ETDMarker: 'HD'
                };
                expect(scope.getCondition(port)).toBe(5);
                port.ETDMarker = 'ETD';
                expect(scope.getCondition(port)).toBe(5);
                port.AAMarker = 'Anchor aweigh';
                expect(scope.getCondition(port)).toBe(5);
                port.ETDMarker = 'HD';
                expect(scope.getCondition(port)).toBe(5);
            });
            it('get conditions 6', function () {
                scope.isFullfilled = jasmine.createSpy('return true').and.returnValue(true);
                var port = {
                    AAMarker: 'Anchor aweigh',
                    ETAMarker: 'ETA',
                    ETBMarker: 'ATB',
                    ETDMarker: 'HD'
                };
                expect(scope.getCondition(port)).toBe(6);
            });

            it('get conditions 0', function () {
                scope.isFullfilled = jasmine.createSpy('return true').and.returnValue(true);
                var port = {
                    AAMarker: '',
                    ETAMarker: 'ETA',
                    ETBMarker: 'ETB',
                    ETDMarker: 'HD'
                };
                expect(scope.getCondition(port)).toBe(0);
                port.ETDMarker = 'ETD';
                expect(scope.getCondition(port)).toBe(0);
                port.ETBMarker = 'ATB';
                expect(scope.getCondition(port)).toBe(0);
                port.AAMarker = 'Anchor aweigh';
                expect(scope.getCondition(port)).toBe(0);
            });
        });
        describe('totalController', function () {
            beforeEach(inject(function ($rootScope, $controller) {
                scope = $rootScope.$new();
                controller = $controller('totalController', {
                    '$scope': scope
                });
            }));
            it('check lay time', function () {
                scope.lay = { Time: '', TimeNum: 0 };
                scope.check();
                expect(scope.lay.Time).toBe('0');
                expect(scope.lay.TimeNum).toBe(0);

                scope.lay = { Time: '012', TimeNum: 0 };
                scope.check();
                expect(scope.lay.Time).toBe('12');
                expect(scope.lay.TimeNum).toBe(12);

                scope.lay = { Time: '4325', TimeNum: 0 };
                scope.check();
                expect(scope.lay.Time).toBe('4325');
                expect(scope.lay.TimeNum).toBe(4325);

                scope.lay = { Time: '4325576', TimeNum: 43255 };
                scope.check();
                expect(scope.lay.Time).toBe('43255');
                expect(scope.lay.TimeNum).toBe(43255);
            });
        });
    });

    describe('ShipApp', function () {
        var scope;
        var controller;
        var $provide;
        var Services;
        var myServiceName = function ($http) {
            // do stuff
        };

        beforeEach(function () {
            module('ShipApp');
            module(function ($provide) {
                $provide.service('Services', myServiceName);
            });
            inject(function ($injector) {
                Services = $injector.get('Services');
            });
        });

        describe('MyCtrl', function () {
            beforeEach(inject(function ($rootScope, $controller) {
                scope = $rootScope.$new();
                controller = $controller('MyCtrl', {
                    '$scope': scope
                });
            }));
            it('delete time zone from date', function () {
                expect(scope.returnDateOfZone(null)).toBe(null);
                var dt = new Date();
                var dt2 = new Date();
                dt2.setHours(dt.getHours() + dt.getTimezoneOffset() / 60)
                expect(scope.returnDateOfZone(dt).getTime()).toBe(dt2.getTime());
            });
            it('add time zone on date', function () {
                expect(scope.returnDateOfZone(null)).toBe(null);
                var dt = new Date();
                var dt2 = new Date();
                dt2.setHours(dt.getHours() - dt.getTimezoneOffset() / 60)
                expect(scope.returnDateOnZone(dt).getTime()).toBe(dt2.getTime());
            });
            it('set type on', function () {
                expect(scope.setTypeOf('SingleVoyage')).toBe('VOY');
                expect(scope.setTypeOf('CoaVoyage')).toBe('COA');
                expect(scope.setTypeOf('qwerty')).toBe('qwerty');
            });
            it('set type off', function () {
                expect(scope.setTypeOn('VOY')).toBe('SingleVoyage');
                expect(scope.setTypeOn('COA')).toBe('CoaVoyage');
                expect(scope.setTypeOn('qwerty')).toBe('qwerty');
            });
            it('check unique name', function () {
                var array = [{ Name: '1234' }, { Name: 'qwerty' }, { Name: 'VOY' }, { Name: 'cort' }];
                expect(scope.uniqueName(array, 'VOY', 2)).toBe('VOY');
                array = [{ Name: '1234' }, { Name: 'qwerty' }, { Name: 'VOY' }, { Name: 'VOY' }];
                expect(scope.uniqueName(array, 'VOY', 2)).toBe('VOY*');
                array = [{ Name: '1234' }, { Name: 'VOY' }, { Name: 'VOY' }, { Name: 'VOY*' }];
                expect(scope.uniqueName(array, 'VOY', 2)).toBe('VOY**');
            });
            it('check is date', function () {
                var dt = new Date();
                expect(scope.checkDate(dt).getTime()).toBe(dt.getTime());
                expect(scope.checkDate(null)).toBe(null);
                expect(scope.checkDate(undefined)).toBe(null);
                expect(scope.checkDate('')).toBe(null);
            });
        });
    });
});